import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:testui/gen/assets.gen.dart';

///
///  Image  图片控件
///  https://api.flutter-io.cn/flutter/widgets/Image-class.html
///
///  利用 Flutter_gen 读取本地图片
///   学习使用lottie 进行图片动画
///
///
///
///
class ImagePage extends StatelessWidget {



  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text("图片组件使用"),
      ),
      body: ListView(
        children: [
          Center(
            child: Image(
              image: AssetImage('assets/images/image01.jpeg'),
              width: 100.0,
              height: 100.0,
              //图片缩放模式
              fit: BoxFit.fill,
              //图片的混合色值
              color: Colors.blue,
              //混合模式
              colorBlendMode: BlendMode.colorDodge,
            ),
          ),

          Center(
            child: MyAssets.images.image01.image(
              width: 100, height: 100,
              //图片缩放模式
              fit: BoxFit.fill,
              //图片的混合色值
              color: Colors.blue,
              //混合模式
              colorBlendMode: BlendMode.colorDodge,
            ),
          ),

          MyAssets.svgs.loading.svg(
              width: 100,
             height: 100
          ),

          MyAssets.gifs.loading.image(
            width: 100,
            height: 100
          ),

          CachedNetworkImage(
            imageUrl: "http://via.placeholder.com/200x200",
            placeholder: (context, url) =>   MyAssets.gifs.loading.image(),
            errorWidget: (context, url, error) => Icon(Icons.error),
            imageBuilder: (context,imageProvider)=> Container(
              decoration: BoxDecoration(
                image: DecorationImage(
                  image: imageProvider,
                  fit: BoxFit.cover,
                  colorFilter: ColorFilter.mode(Colors.red, BlendMode.colorBurn)
                )
              ),
            ),
            width: 200,
            height: 150,
          ),
          //加载网络图片
          Image.network(
            "https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF",
            width: 100.0,
            height: 100.0,
          )

        ],
      ),
    );
  }
}
